import axios from 'axios'
import qs from 'qs'
import {Promise} from 'core-js'

const request = axios.create({
    baseURL: 'http://localhost:3000'
})

request.interceptors.request.use(
    config => {
        config.method == 'post' ? config.data = qs.stringify({ ...config.data }) : config.params = { ...config.params }
        config.headers['Content-Type'] = 'application/x-www-form-urlencoded';
        return config
    },
    error => {
        return Promise.reject(error)
    }
)

request.interceptors.response.use(
    response=>{
        return response
    },
    error => {
        return Promise.reject(error)
    }
)
export default request